﻿CREATE PROCEDURE [dbo].[proc_Finance_Subject_GetList]

AS
	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY Id)AS Row,
	Id,
	SId,
	ParentOldId,
	CateOneId,
	CateTwoId,
	Title,
	Description,
	Sort,
	CreateDate,
	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateOneId),'---') As CateOne,
	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateTwoId),'---') As CateTwo,
	Isnull((Select Title From Finance_Subject_ParentOld Where Id=Finance_Subject.ParentOldId),'---') As ParentOldName
	From Finance_Subject
	
	)
	Select * From list
	RETURN

--======================================
--2012 01 08 将上面代码替换下面代码 @XFL
--======================================
--set ANSI_NULLS ON
--set QUOTED_IDENTIFIER ON
--go
--
--ALTER PROCEDURE [dbo].[Finance_Subject_GetList]
--(
--@typeid int	
--)
--
--AS
--	;WITH list As(Select ROW_NUMBER() OVER (ORDER BY Id)AS Row,
--	Id,
--	SId,
--	ParentId,
--	ParentOldId,
--	CateOneId,
--	CateTwoId,
--	Title,
--	Description,
--	Sort,
--	CreateDate,
--	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateOneId),'---') As CateOne,
--	Isnull((Select Title From Finance_Subject_Parent Where Id=Finance_Subject.CateTwoId),'---') As CateTwo,
--	Isnull((Select Title From Finance_Subject_ParentOld Where Id=Finance_Subject.ParentOldId),'---') As ParentOldName
--	From Finance_Subject WHERE TypeId=@typeid
--	
--	)
--	Select * From list
--	RETURN
